package com.qire.manhua.activity;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;

import com.qire.antscore.annotation.RouteMapping;
import com.qire.antsrouter.inject.Autowired;
import com.qire.common.constant.CustomEvent;
import com.qire.common.constant.Navigation;
import com.qire.common.support.base.BaseActivity;
import com.qire.common.utils.NoticeEventBus;
import com.qire.manhua.R;
import com.qire.manhua.databinding.ActivityImageCutAndScaleBinding;

import androidx.annotation.Nullable;

@RouteMapping(path = Navigation.Page.ImageCutAndScalePage)
public class ImageCutAndScaleActivity extends BaseActivity<ActivityImageCutAndScaleBinding> {

    @Autowired
    Bitmap bitmap;
    @Autowired
    int cropWidth;
    @Autowired
    int cropHeight;

    @Override
    public int layoutRid() {
        return R.layout.activity_image_cut_and_scale;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        viewDataBinder().cropImageView.setDrawable(new BitmapDrawable(getResources(), bitmap), cropWidth, cropHeight);
    }

    public void cancelBtnOnClick(View view){
        finish();
    }

    public void confirmBtnOnClick(View view){
        Bitmap bitmap = viewDataBinder().cropImageView.getCropImage();
        NoticeEventBus.NOTICE.sendEvent(CustomEvent.IMAGE_CUT_AND_SCALE, bitmap);
        finish();
    }

}
